package com.team.mp.api.controller;

import com.team.mp.api.bo.ResidentBasicInfoBo;
import com.team.mp.api.service.intf.ResidentDetailService;
import com.team.mp.mapper.entity.ResidentDetail;
import com.team.mp.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.*;

/**
 * @program: TProject_Mapper
 * @description: 控制层实现常用的外部接口
 * @author: aming
 * @create: 2023-03-27 17:52:13
 */
@RestController
@RequestMapping("/api/residentDetail/")
@Api(tags = "居民管理的相关接口")
public class ResidentDetailController {
    /**
     * 注入业务逻辑层对象
     */
    @Resource
    private ResidentDetailService service;

    /**
     * 新增居民基础信息
     */
    @ApiOperation(value = "实现新增-居民基础信息")
    @PostMapping("savebasic.do")
    public R saveBasic(@RequestBody ResidentBasicInfoBo bo) {
        return service.saveBasic(bo);
    }

    /**
     * 修改内容
     */
    @ApiOperation(value = "实现完成和编辑居民信息")
    @PostMapping("update.do")
    public R update(@RequestBody ResidentDetail residentDetail) {
        return service.update(residentDetail);
    }

    /**
     * 查询 所有数据
     */
    @ApiOperation(value = "实现全部查询")
    @GetMapping("all.do")
    public R all() {
        return service.queryAll();
    }

    /**
     * 查询 所有数据
     */
    @ApiOperation(value = "实现查询单个")
    @GetMapping("single.do")
    public R single(long id) {
        return service.queryById(id);
    }

    /**
     * 删除 单个数据
     */
    @ApiOperation(value = "实现删除")
    @DeleteMapping("del.do")
    public R del(long id) {
        return service.del(id);
    }

    /**
     * 条件分页查询
     */
    @ApiOperation(value = "实现条件分页查询")
    @GetMapping("page.do")
    public R page(int page,
                  int size,
                  String state,
                  String deptname,
                  String teamname,
                  String packname) {
        return service.queryPage(page, size, state, deptname, teamname, packname);
    }

}